<?php
namespace app\admin\controller;
use \think\Controller;
use \think\Db;
class user extends Controller
{
    public function index(){
    	$users=Db::name("users")->select();
    	$this->assign("ulist",$users);
    	return $this->fetch();
    }

    public function delete($id){
    	//删除头像：find方法和unlink；
    	//
    	if(db::name("users")->delete($id)){
    		$this->success('删除成功');

    	}else $this->error('删除失败');

    }
   public function add(){
    $data=[     'uid'=>'',
                'uname'=>input('param.username'),
                'pic'=>'1.Jpg',
                'password'=>md5(input('param.password')),
                'birthdate'=>date('Y-m-d'),
                'email'=>input('param.email'),
                'gender'=>input('param.gender')];

    
        $res=Db::name("users")->insert($data);
        
        if ($res) {
            $this->success("添加用户成功");
        }else{
            $this->error("添加用户失败");
      }

   }
}
